#ifndef CAMERA_H
#define CAMERA_H

#define PI 3.1415926535897932384626433832795

#include <gtypes/Vector3.h>
#include <gtypes/Vector2.h>

#include <cmath>

#include "renderer.h"

class Camera
{
public:
   Camera( Renderer *renderer = 0 );
   
   /**
   * Sets renderer for camera to use.
   * @param renderer A pointer to usable renderer
   */
   void setRenderer( Renderer *renderer );
   /**
   * Returns a pointer to renderer in use.
   * @param Renderer
   */
   Renderer *renderer();
   
   /**
   * Updates camera position and orientation.
   * Call this function in a game loop every time before calling render on renderer
   */
   void update();
   
   /**
   * Rotates camera around x axis by angle.
   * @param angle - angle in degrees
   */
    void rotateX ( float angle );
    
   /**
   * Rotates camera around y axis by angle.
   * @param angle - angle in degrees
   */
    void rotateY ( float angle );
    
   /**
   * Rotates camera around z axis by angle.
   * @param angle - angle in degrees
   */
    void rotateZ ( float angle );

    /**
    * Moves camera forward.
    * or backward if distance is negative
    * @param distance
    */
    void moveForward ( float distance );
    
    /**
    * Moves camera upward.
    * or downward if distance is negative
    * @param distance
    */
    void moveUpward ( float distance );
    
    /**
    * Moves camera to right (without changing it's orientation).
    * or to left if distance is negative
    * @param distance
    */
    void strafeRight ( float distance );

private:
   Renderer *m_renderer;
   
    gtypes::Vector3 m_position, m_viewDir, m_upVector, m_rightVector;
    float m_rotatedX, m_rotatedY, m_rotatedZ;
};


#endif // CAMERA_H
